/// <reference types="vitest" />
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import dts from 'vite-plugin-dts'
import { resolve } from 'path'
import autoInstall from 'unplugin-vue-components/vite'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    autoInstall({
      dts: true,
      globs: ['./src/components/*.{vue}'],
      extensions: ['vue'],
    }),
    dts({ 
      include: './src/components/', 
      tsconfigPath: './tsconfig.app.json', 
    }),
  ],
  build: {
    minify: 'esbuild',
    target: 'esnext',
    terserOptions: {
      compress: {
        drop_console: true,
        drop_debugger: true,
      },
    },
    lib: {
      entry: resolve(__dirname, 'src/components/index.ts'),
      name: 'CxyLib',
      fileName: 'index',
    },
    rollupOptions: {
      external: ['vue'],
      output: {
        globals: {
          vue: 'Vue',
        },
      },
    },
  },
  test: {
    environment: 'happy-dom', // 添加这行
    globals: true
  }
})
